import { connect } from "react-redux";
import React from "react";
// judge手动控制
// remove 移除
// disabled禁用
const Authority = (props) => {
  const { children, role, mode = "remove", judge = (r) => r > 1 } = props;
  if (mode === "remove") return judge(role) ? children : null;
  if (mode === "disabled") {
    const item = React.cloneElement(children, { disabled: !judge(role) });
    return item;
  }
  return children;
};
export default connect((state) => state.authority)(Authority);
